package com.singerw.controller;

import com.singerw.annotations.ResponseResult;
import com.singerw.annotations.UserName;
import com.singerw.pojo.TwCollege;
import com.singerw.service.security.TwCollegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version V1.0
 * @Package com.singerw.controller
 * @auhter 张欣
 * @date 2021/1/30-3:55 PM
 */

@RestController
@RequestMapping("/college")
public class TwCollegeController {

    @Autowired
    private TwCollegeService twCollegeService;

    @GetMapping("/findByUserNameIsAdmin/{collegeName}")
    @ResponseResult
    private boolean findByUserNameIsAdmin(@PathVariable("collegeName") String collegeName, @UserName String userName){
        return twCollegeService.findByUserNameIsAdmin(collegeName,userName);
    }

    @GetMapping("/list")
    @ResponseResult
    private List<TwCollege> list(){
        return twCollegeService.list();
    }

    @PostMapping("/add")
    @ResponseResult
    private void save(@RequestBody TwCollege twCollege){
        twCollegeService.save(twCollege);
    }


}
